package com.gxuwz.attend.service.instructor;


import com.gxuwz.attend.dao.instructor.StudentDao;
import com.gxuwz.attend.entity.Student;

import java.util.List;

public class StudentService {
    private StudentDao studentDao;

    public void setStudentDao(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    // 获取所有学生
    public List<Student> getAllStudents(String stuID, String stuName, int size, int offset) {
        // 如果学号和姓名都为空，返回所有学生
        if ((stuID == null || stuID.isEmpty()) && (stuName == null || stuName.isEmpty())) {
            return studentDao.getAllStudents(size, offset); // 调用DAO获取所有学生
        } else {
            return studentDao.findStudents(stuID, stuName, size, offset);
        }
    }

    // 添加学生
    public void addStudent(Student student) {
        studentDao.addStudent(student); // 调用DAO添加学生
    }

    // 删除学生
    public void deleteStudent(String stuID) {
        studentDao.deleteStudent(stuID); // 调用DAO删除学生
    }

    // 更新学生信息
    public void updateStudent(Student student) {
        studentDao.updateStudent(student); // 调用DAO更新学生
    }
}
